const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const cors = require('cors');

const _route = require("./routes/router");
const {Router} = require("express");
const {buildRoutes, routes} = require("./routes/router");
const {connectMysql} = require("./core/config/database");
const Logger = require("./core/utils/Logger");
const {printBanner} = require("./core/banner/banner");
require("../admin/database/modes")
printBanner();

const app = express();
app.use(logger('dev'));
app.use(cors({
    origin: "*",
}))
app.use(express.json());
app.use(express.urlencoded({extended: false}));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));


Logger.log("\n\n\t\t\t\t接口路由表\t\t\t\t")
Logger.log("==================================================================================")
buildRoutes(app, routes)
Logger.log("==================================================================================")


module.exports = {
    app
};
